//左边菜单
Ext.user.MyAsyncTreeNode1Ui = Ext.extend(Ext.tree.AsyncTreeNode, {
    constructor: function(cfg) {
        cfg = cfg || {};
        Ext.user.MyAsyncTreeNode1Ui.superclass.constructor.call(this, Ext.apply({
            text: '主菜单',
            id:'menu'
        }, cfg));
    }
});

Ext.user.MyTreeLoaderUi = Ext.extend(Ext.tree.TreeLoader, {
    constructor: function(cfg) {
        cfg = cfg || {};
        Ext.user.MyTreeLoaderUi.superclass.constructor.call(this, Ext.apply({
            dataUrl: Ext.user.baseUrl + '/Index/tree/',
				 nodeParameter: 'p'
        }, cfg));
    }
});
Ext.user.MyTree = function (){
	return new Ext.tree.TreePanel({
                xtype: 'treepanel',
                title: '菜单项',
                region: 'west',
                width: 200,
                singleExpand: true,
                collapsible: true,
                collapseFirst: false,
				animate:true,
				frame:true,	
                root: new Ext.user.MyAsyncTreeNode1Ui(),
                loader: new Ext.user.MyTreeLoaderUi(),
				listeners:{
					click:function(n,e){
						if(n.isLeaf()){ //打开tab
							var tabvalue = n.attributes;
							var center = Ext.getCmp('center');
							if(!Ext.get('center_' + tabvalue.id)){
								tab = center.add({
									xtype:'panel',
									id: 'center_' + tabvalue.id,
									title: tabvalue.text,
									html:'<iframe width="100%" height="100%" frameborder="no" id="center_iframe_'+ tabvalue.id +'" src="'+ Ext.user.baseUrl + '/' + tabvalue.url + '/' +'">',
									closable:true,
									scripts: true,
									nocache: true
								});
								center.setActiveTab(tab);
							}else{
								center.setActiveTab('center_' + tabvalue.id);
							}
						}
							
					}
					
				}
            });
}